package com.examsage.examsage.controller;

import com.examsage.examsage.model.MajorPlan;
import com.examsage.examsage.model.vo.ResponseVO;
import com.examsage.examsage.service.IMajorPlanService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author examsage
 * @since 2025-07-02
 */
@RestController
@RequestMapping("/api/v1/major-plans")
public class MajorPlanController {

    @Autowired
    private IMajorPlanService majorPlanService;

    @PostMapping("/")
    public ResponseVO add(MajorPlan majorPlan) {
        // TODO  增加专业计划
        return majorPlanService.addMajorPlan(majorPlan);
    }

    @GetMapping("/")
    public ResponseVO selectMajorPlan(@RequestParam int page, int size, String majorName, Boolean status) {
        // TODO 查询专业计划列表（支持分页和条件查询）
        return majorPlanService.selectMajorPlan(page, size, majorName, status);
    }

    @GetMapping("/{id}")
    public ResponseVO selectOneMajorPlan(@PathVariable Long id) {
        // TODO  查询专业计划详情
        return majorPlanService.selectOneMajorPlan(id);
    }

    @PostMapping("/{id}")
    public ResponseVO updateMajorPlan(@PathVariable Long id, MajorPlan majorPlan) {
        // TODO  修改专业计划
        return majorPlanService.updateMajorPlan(id, majorPlan);
    }

    @DeleteMapping("/{id}")
    public ResponseVO deleteMajorPlan(@PathVariable Long id) {
        return majorPlanService.deleteMajorPlanById(id);
    }
}
